package com.example.demo.controller;

import com.example.demo.entity.Admin;
import com.example.demo.entity.Image;
import com.example.demo.service.Impl.AdminServiceImpl;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

//用户操作接口
@RestController
@RequestMapping("/Admin")
public class AdminController {
    AdminServiceImpl adminserviceimpl=new AdminServiceImpl();
//    用户登录
    @ResponseBody
    @RequestMapping("/AdminRegister")
    public List<Admin> AdminRegister(String admin, String admin_psw){
        List<Admin> list=new ArrayList<>();
        if(admin.length()!=0&&admin_psw.length()!=0){
            list= adminserviceimpl.AdminRegister(admin, admin_psw);
        }
        return list;
    }

//    用户修改密码
    @RequestMapping("/AdminUpdate_pws")
    public boolean AdminUpdate_pws(String admin,String admin_psw,String newadmin_psw){
        if(admin.length()!=0&&admin_psw.length()!=0&&newadmin_psw.length()!=0){
            if(adminserviceimpl.AdminUpdate_pws(admin, admin_psw, newadmin_psw)){
                return true;
            }else{
                return false;
            }
        }else{
            return false;
        }
    }

//    用户注销账号
    @RequestMapping("/Admindelete")
    public boolean Admindelete(String admin,String admin_psw){
        if(admin.length()!=0&&admin_psw.length()!=0){
            if(adminserviceimpl.Admindelete(admin, admin_psw)){
                return true;
            }else{
                return false;
            }
        }else{
            return false;
        }
    }

//    用户添加

    @RequestMapping("/Admindeletadd")
    public boolean Admindeletadd(String admin,String admin_psw){
        if(admin.length()!=0&&admin_psw.length()!=0){
            if(adminserviceimpl.Admindeletadd(admin, admin_psw)){
                return true;
            }else {
                return false;
            }
        }else {
            return false;
        }
    }
}
